** running this script in its entirety will reproduce tables 2 and 3 from the article **
** be warned that the hierarchical model at the end of the script may be computationally taxing on most machines **
** be sure to set your working directory  appropriately before beginning the script **

	quietly {
	clear
	clear mata
	clear matrix

	set mem 1g

	set more off

** uncomment directory command below and set to location of replication data **

	cd "/Users/david/Dropbox/Fortunato Paper/AJPS revision/finalManuscript"
	use "replicationData.dta", replace

** Execute models **
	
/* specifications with and without education */


	noisily: display "Here are the results for the specifications found in Table 2." 
	noisily: display "Label each model 1,  model 2, etc. (we will follow this with the standard error clusters"
	noisily: display "and a multilevel model for the prefered specification). The estimates are followed by" 
	noisily: display "calulations of the number of units at various levels,"
	noisily: display ""
	noisily: display "note that the coding of the surveymode variable"
	noisily: display "is 1= in person interview, 2=telephone, 3=self adminstered"
	noisily: display ""

	local varstouse1 = "absRespDist absCmpAvg10 absCmpProx coalPartners oppoPartners polInt intXcoal intXoppo betweenParties absRespExtreme disXXpair9 fampos coalXfamiliar9 oppoXfamiliar9 i.surveymode"
	local varstouse2 = "absRespDist absCmpAvg10 absCmpProx coalPartners oppoPartners polInt intXcoal intXoppo betweenParties absRespExtreme i.surveymode"
	local varstouse3 = "absRespDist absCmpAvg10 absCmpProx coalPartners oppoPartners educ educXcoal educXoppo betweenParties absRespExtreme disXXpair9 fampos coalXfamiliar9 oppoXfamiliar9 i.surveymode"
	local varstouse4 = "absRespDist absCmpAvg10 absCmpProx coalPartners oppoPartners educ educXcoal educXoppo betweenParties absRespExtreme i.surveymode"
	
	regress `varstouse1'
	
	foreach est of numlist 1 2 3 4 {
		noisily regress `varstouse`est''

		if `est'==1|`est'==3 {
		}
		
		noisily: regress `varstouse`est'', cluster(manicountry)
		noisily: display "countries: " e(N_clust) "  obs: " e(N)
		noisily: display ""
		
		if `est'==1|`est'==3 {
		}
		
		noisily: regress `varstouse`est'', cluster(studylabnum)
		noisily: display "surveys: " e(N_clust) "  obs: " e(N)
		noisily: display ""
		
		if `est'==1|`est'==3 {
		}
		
		noisily: regress `varstouse`est'', cluster(uniqueDyadId)
		noisily: display "party dyads accross surveys: " e(N_clust) "  obs: " e(N)
		noisily: display ""
		
		if `est'==1|`est'==3 {
		}

		noisily: regress `varstouse`est'', cluster(dyadIdAccrossSurveys)
		noisily: display "unique (within surveys) party dyads: " e(N_clust) "  obs: " e(N)
		noisily: display ""
		
		if `est'==1|`est'==3 {
		}
		
		noisily: regress `varstouse`est'', cluster(respondent)
		noisily: display "respondents: " e(N_clust) "  obs: " e(N)
		noisily: display ""
		
		if `est'==1|`est'==3 {
		}
		
		noisily: xi: sum `varstouse`est'' if e(sample)==1
		noisily: display ""
	}
						 

	noisily: display ""
	noisily: display "********************************"
	noisily: display ""
	noisily: display "Here is the mixed model"

	noisily: xi: xtmixed absRespDist absCmpAvg10 absCmpProx coalPartners oppoPartners polInt intXcoal intXoppo betweenParties absRespExtreme disXXpair9 fampos coalXfamiliar9 oppoXfamiliar9  i.surveymode || studylabnum: || uniqueDyadId:	 		

}
